#工具类
import hmac, random

def hmac_md5(key, s):
    """MD5加密"""
    return hmac.new(key.encode('utf-8'), s.encode('utf-8'), 'MD5').hexdigest()

def salt_passwd(password):
    """输入密码得到随机盐以及加密之后的密码"""
    key = ''.join([chr(random.randint(48, 122)) for i in range(10)])
    passwd = hmac_md5(key, password)
    return key,passwd
